package Test;

/**
 * Created by 春旺 on 2017/5/2.
 */
import java.lang.reflect.Array;
import java.util.*;

public class MySort {
    public static void main(String [] args) {
        String [] toSort = {
                            "aaa:10:1:1",
                            "ccc:30:3:4",
                            "bbb:50:4:5",
                            "ddd:20:5:3",
                            "eee:40:2:20"
                          };

        System.out.println("Before sort:");
        for (String str: toSort)
        System.out.println(str);

        //sort
       int [] k3 = new int [toSort.length];
       for(int i  =0 ; i< toSort.length; i ++)
       {
           String []temp = toSort[i].split(":");
                   k3 [i]  = Integer.parseInt(temp[1 ]);
       }
        Arrays.sort(k3);
       System.out.println("After sort:");
       for(int i = 0;i<k3.length;i++) {

           for (int j = 0; j < toSort.length; j++) {

               String[] temp = toSort[j].split(":");
               if (Integer.parseInt(temp[1]) == k3[i]) {
                   System.out.println(toSort[j]);
               }
           }
       }

    }
}
